﻿<cfscript>
/** 
* ORM TaskAdjust
* 
* @hint "Hibernate persistenter t_task_adjust. 教学任务更改情况记录" 
* 
*/ 

component 
	displayname="public.service.orm.senate.TaskAdjust" 
	output=false 
	persistent=true 
	selectBeforeUpdate=true dynamicInsert=true dynamicUpdate=true 
	cacheuse="Transactional" 
	entityname="TaskAdjust" 
	table="t_task_adjust"
	{

	property type="string" name="SignID" column="sign_id" fieldtype="id" generator="assigned" hint="申请流水单号";
	
	property type="string" name="ChangeType" column="change_type" hint="更改类别";
	property type="string" name="TaskID" column="task_id" hint="教学任务号";
	property type="string" name="TaskType" column="task_type" hint="教学任务类别";
	property type="string" name="ChangeReason" column="change_reason" hint="调停课原因";
	property type="string" name="ChangeTarget" column="change_meta" hint="教学任务调整元素";
	property type="string" name="ChangeDescription" column="change_desc" hint="教学任务调整内容";
	property type="string" name="SignStatus" column="sign_status" hint="处理状态";
	
	property type="string" name="DateCreated" column="date_created" hint="申请时间";
	property type="string" name="DateReview" column="date_review" hint="处理时间";
	
	property name="Term" fieldtype="many-to-one" fkcolumn="term_id" cfc="Term" hint="学期";
	property name="Course" fieldtype="many-to-one" fkcolumn="cid" cfc="Course"  hint="课程";
	property name="Teacher" fieldtype="many-to-one" fkcolumn="sign_user_id" cfc="Teacher"  hint="申请教师";
	property name="Admin" fieldtype="many-to-one" fkcolumn="admin_user_id" cfc="Teacher"  hint="管理岗位教师";

	/**
	* @hint "自定义主键规则"
	*/
	public string function getNextID() output=false {
		
		var nextID = year(now()) & numberFormat(1, "0_____");
		
		var checkArray = ORMExecuteQuery("select SignID from TaskAdjust 
											where SignID like :condition 
											order by SignID desc", {condition = year(now()) & "______"}, { maxResults=1 });
		
		/* 
			主键生成规则 
			
			4位年份 + 6位流水号
			
		*/
		if (arrayLen(checkArray)) {
			/* 创建一个追加id */
			nextID = year(now()) & numberFormat((right(checkArray[1], 6) + 1), "0_____");
			
		}

		return nextID;
	}
	
}

</cfscript>